<?php
    //$_GET['delete']!=0 delete sprint with that id
    include "../database.php";
    $sprint_id = $_GET['sprint_id'];
    
    if(isset($_GET['delete']) && $sprint_id != 0){
            $query = "SELECT sprint_number, project_id FROM sprint WHERE sprint_id = '$sprint_id'";
            $row = mysql_fetch_array(executeQuery($query));
            $sprint_number = $row[0];
            $project_id = $row[1];
            //Popravimo še naslednje sprinte, če smo izbrisali kakšnega vmes
            $query = "UPDATE sprint SET sprint_number = sprint_number-1 WHERE sprint_number > '$sprint_number' AND project_id = '$project_id'";
            executeQuery($query);
            $query = "DELETE FROM sprint WHERE sprint_id = '$sprint_id'";
            if(executeQueryRowsAffected($query)>0){
                echo "1";
            }
            else echo "0";
    }
    
    //Update velocity
    if(isset($_GET['velocity'])){
        $velocity = $_GET['velocity'];
        $query = "UPDATE sprint SET velocity = '$velocity' WHERE sprint_id = '$sprint_id'";
        
        if(executeQueryRowsAffected($query)>0){
            echo "1";
        }
        else echo "0";
    }
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
